"""
get remote file size through http
The requirement is to get the size of a remote file (http). 

    Now here is a very stupid solution for this:
    import urllib2
    
    url = 'http://abc.com/dir/file1.mp3'
    usock = urllib2.urlopen(url)
    data = usock.read()
    size = data.__len__() # size in bytes
    size = size / 1024.0 # in KB (Kilo Bytes)
    size = size / 1024.0 # size in MB (Mega Bytes)
    ...


The stupidity happens in this line: data = usock.read() where the whole file 
is being read to get it's size! This solution came to my mind first. 
But soon I understood that the file size can be found from the http response header. 
Here is a much better solution:
"""

import urllib2

url = 'http://www.frekvence1.cz/file/cms/cs/zabava/podcast/kraus_a_blondynka/kraus_04-25-08.mp3'
usock = urllib2.urlopen(url)
size =  usock.info().get('Content-Length')
if size is None:
    size = 0
size = int(size) # in bytes
ksize = size / 1024.0 # in KB (Kilo Bytes)
msize = ksize / 1024.0 # size in MB (Mega Bytes)

print url
print size, ksize, msize
print usock.info()